#include <vector>
#include <list>
#include <string>
#include <gtest/gtest.h>
#include "strutil.h"

using acutil::string::Join;
//using acutil::string::Split;

namespace {
  class JoinSplitTest : public testing::Test{
  public:
    JoinSplitTest()
     : space_split_string_("  foo  bar  Foo  foob  Ar"),
       empty_string_(L""),
       twospace_string_("  "),
       fourspace_string_(L"    "),
       two_twospace_string_(2, L"  "){
       space_split_string_children_.push_back("");
       space_split_string_children_.push_back("foo");
       space_split_string_children_.push_back("bar");
       space_split_string_children_.push_back("Foo");
       space_split_string_children_.push_back("foob");
       space_split_string_children_.push_back("Ar");
    }
  protected:
    std::string space_split_string_;
    std::string twospace_string_;
    std::wstring empty_string_;
    std::wstring fourspace_string_;
    std::vector<std::wstring> empty_string_list_;
    std::vector<std::wstring> two_twospace_string_;
    std::list<std::string> space_split_string_children_;
  };

  template< typename Container1, typename Container2 >
  bool ContentEqual(const Container1& list1, const Container2& list2) {
    if (list1.size() != list2.size())
      return false;
    for (Container1::const_iterator it1 = list1.begin(), Container2::const_iterator it2 = list2.begin();
         it1 != list1.end() && it2 != list2.end();
         ++it1, ++it2){
      if (*it1 != *it2)
        return false;
    }
    return true;
  };
} // namespace

TEST_F(JoinSplitTest, Join) {
  EXPECT_STREQ(empty_string_.c_str(), Join(empty_string_list_, empty_string_).c_str());
  EXPECT_STREQ(fourspace_string_.c_str(), Join(two_twospace_string_, empty_string_).c_str());
  EXPECT_STREQ(space_split_string_.c_str(), Join(space_split_string_children_, twospace_string_).c_str());
}